<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>首页图片管理</title>
<%@ include file="/base/jsp/include.jsp"%>
</head>
<body>
	<div class="mini-toolbar" style="padding:2px;border-bottom:0;">
		<table style="width:100%;">
			<tr>
				<td style="width:100%;"><a class="mini-button"
					iconCls="icon-remove" plain="true" onclick="del()">删除</a><span
					class="separator"></span><a class="mini-button"
					iconCls="icon-cancel" plain="true" href="javascript:clearFilter()">清除筛选</a></td>
			</tr>
		</table>
	</div>
	<!--撑满页面-->
	<div class="mini-fit">
		<div id="grid" class="mini-datagrid" style="width:100%;height:100%;"
			pageSize="20" borderStyle="border:1;" url="listUser.do" idField="id"
			multiSelect="true" showFilterRow="true">
			<div property="columns">
				<div type="checkcolumn" field="bCategoryId"></div>
				<div type="indexcolumn" headerAlign="center">序号</div>
				<div field="username" width="50" headerAlign="center" align="center">登录名</div>
				<div field="phone" width="50" headerAlign="center" align="center">手机</div>
				<div field="mail" width="50" headerAlign="center" align="center">邮箱</div>
				<div field="sName" width="30" headerAlign="center" align="center">学校</div>
				<div field="dmName" width="30" headerAlign="center" align="center">院系
				<input id="dmNameFilter" property="filter" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/></div>
				<div field="mjName" width="30" headerAlign="center" align="center">专业</div>
				<div field="address" width="30" headerAlign="center" align="center">地址</div>
				<div field="qqNumber" width="30" headerAlign="center" align="center">QQ号</div>
				<div field="entranceDate" width="100" headerAlign="center"
					align="center" dataType="date" dateFormat="yyyy-MM-dd" allowSort="true">入学时间</div>
				<div field="createTime" width="100" headerAlign="center"
					align="center" dataType="date" dateFormat="yyyy-MM-dd HH:mm:ss" allowSort="true">注册时间</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	var dmName = '';
	mini.parse();
	var grid = mini.get("grid");
	grid.load();
	function addRow() {
		mini.open({
			url : "toEditUser.do",
			title : "用户",
			width : 500,
			height : 400,
			onload : function() {
				var iframe = this.getIFrameEl();
				var data = {
					action : "new"
				};
				iframe.contentWindow.SetData(data);
			},
			ondestroy : function(action) {
				grid.reload();
			}
		});
	}

	function del() {
		var rows = grid.getSelecteds();
		if (rows.length > 0) {
			mini.confirm("确定删除吗？", "确定？", function(action) {
				if (action == "ok") {
					var ids = [];
					for ( var i = 0, l = rows.length; i < l; i++) {
						var r = rows[i];
						ids.push(r.id);
					}
					var id = ids.join(',');
					grid.loading("操作中，请稍后......");
					$.ajax({
						url : "delUser.do?id=" + id,
						success : function(text) {
							grid.reload();
						},
						error : function() {
						}
					});
				}
			});
		} else {
			mini.alert("请选中一条记录");
		}
	}

	function edit() {
		var rows = grid.getSelecteds();
		if (rows.length == 1) {
			var row = grid.getSelected();
			mini.open({
				url : "toEditUser.do",
				title : "用户编辑",
				width : 600,
				height : 400,
				onload : function() {
					var iframe = this.getIFrameEl();
					var data = {
						action : "edit",
						id : row.id
					};
					iframe.contentWindow.SetData(data);
				},
				ondestroy : function(action) {
					grid.reload();
				}
			});
		} else if (rows.length > 1) {
			mini.alert("只能选一条记录");
		} else {
			mini.alert("请选中一条记录");
		}

	}
	
	function onFilterChanged() {
       var dmNamebox = mini.get("dmNameFilter");
       
       dmName = dmNamebox.getValue().toLowerCase();
       grid.load({dmName: dmName});
   }
	
	function clearFilter() {
	   var dmNamebox = mini.get("dmNameFilter");
	   dmName = '';
       grid.load({dmName: dmName});
   }
</script>
</html>
